﻿using BwTMusicServices.Country;
using BwTMusicServices.Music;
using BwTMusicServices.Singer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BwTMusic.Controllers
{
    public class MusicController : Controller
    {
        CountryServices country = new CountryServices();
        MusicServices music = new MusicServices();
        SingerServices singer = new SingerServices();
        public ActionResult PlayList()
        {
            string key = Request.QueryString["id"];
            ViewBag.key = key;
            return View();
        }
        public ActionResult MusicRank()
        {
            return View();
        }
        public ActionResult NewCd()
        {
            return View();
        }
        public ActionResult MusicType()
        {
            return View();
        }
        public ActionResult Singer()
        {
            return View();
        }
        public ActionResult RecomMusic()
        {
            return View();
        }
        public ActionResult TypeDeilteList()
        {
            string id = Request.QueryString["id"];
            TempData["countryId"] = id;
            ViewData["countryId"] = id;
            return View();
        }
        public ActionResult SingerdetailInfo()
        {
            string id = Request.QueryString["id"];
            ViewData["id"] = id;
            TempData["id"] = id;
            return View();
        }
        public JsonResult GetCountryInfo(string id)
        {
            return Json(new { data = country.GetCountryInfo(TempData["countryId"].ToString()), statusCode = 1, message = "查询成功", success = true }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetCountryMusicLists(int CurrentPage,string CountryId)
        {
            return Json(new { data = music.GetAllNorthMusic(CurrentPage, CountryId, out int total), statusCode = 1, message = "查询成功", success = true, totalCount = total }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetTypeMusicLists(int CurrentPage, string GenreId,string ThemeId)
        {
            return Json(new { data = music.GetAllNorthMusicForType(CurrentPage, GenreId,ThemeId, out int total), statusCode = 1, message = "查询成功", success = true, totalCount = total }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AddClickCount(int id)
        {
            return Json(new { data = music.AddMusicClickCount(id), statusCode = 1, message = "操作成功", success = true }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetAllSingerlist(int CurrentPage,string chars,string countrys)
        {
            return Json(new { data = singer.GetAllNorthSinger(CurrentPage,chars,countrys, out int total), statusCode = 1, message = "查询成功", success = true, totalCount = total }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetSingerInfoById()
        {
            return Json(new { data = singer.GetSingerInfoById(Convert.ToInt32(TempData["id"])), statusCode = 1, message = "查询成功", success = true }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetSingerMusicList(int CurrentPage,int SingerId)
        {          
           return Json(new { data = music.GetAllNorthSingerMusic(CurrentPage, SingerId, out int total), statusCode = 1, message = "查询成功", success = true, totalCount = total }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetSingerAlbumList(int CurrentPage, int SingerId)
        {
            return Json(new { data = music.GetAllNorthSingerAlbum(CurrentPage, SingerId, out int total), statusCode = 1, message = "查询成功", success = true, totalCount = total }, JsonRequestBehavior.AllowGet);
        }
    }
}